package com.lifeonwalden.ms.web.auth;

import com.lifeonwalden.ms.auth.service.PermissionService;
import org.apache.shiro.ShiroException;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

@Service
public class PermissionServiceImpl implements PermissionService {

    @Override
    public List<String> getPermissions(String principal) {
        switch (principal) {
            case "admin": {
                return Arrays.asList("/**");
            }
            case "guest": {
                return Arrays.asList("/guest/**");
            }
            default: {
                return Collections.emptyList();
            }
        }
    }

    @Override
    public boolean isExist(String principal) {
        return "admin".equals(principal) || "guest".equals(principal);
    }

    @Override
    public void init() throws ShiroException {

    }
}
